package com.wxx.tasks;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class AsyncTask {

    @Async
    public Boolean test1(){
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.err.println("task 任务执行" + new Date());
        return true;
    }

    @Async
    public Boolean test2(){
        try {
            Thread.sleep(700);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.err.println("task 任务执行" + new Date());
        return true;
    }

    @Async
    public Boolean test3(){
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.err.println("task 任务执行" + new Date());
        return true;
    }
}
